<template>
  <div>
    <van-list
      style="margin: 10px"
      :finished="finished"
      v-model="loading"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <van-cell
        v-for="(item, index) in list"
        :key="index"
        :title="item.EntranceTypeName"
        :value="item.EntranceDate | formatDateTime"
      >
      </van-cell>
    </van-list>
  </div>
</template>
<script>
import { getPageData } from "@/api/ConstructSafeProjectUserEntrance";
import { mapGetters } from "vuex";
import { getDateTime } from "@/utils/getDate";
export default {
  props: {},
  data() {
    return {
      value: "",
      list: [],
      filter: {
        page: 0,
        dataType: "ScanList",
        code: this.$route.query.code,
      },
      loading: false,
      finished: false,
    };
  },
  created() {
    this.getList();
  },
  filters: {
    formatDateTime: function (value, args) {
      return getDateTime(value);
    },
  },
  computed: {
    ...mapGetters(["roles"]),
  },
  methods: {
    getList() {
      this.loading = true;
      getPageData(this.filter).then((res) => {
        this.loading = false;
        if (!res.data.HasNextPage) {
          this.finished = true;
        }
        this.list = res.data.Data;
        this.filter.page = res.data.PageIndex;
      });
    },
    onLoad() {
      this.loading = true;
      ++this.filter.page;
      list(this.filter).then((res) => {
        this.loading = false;
        this.filter.page = res.data.PageIndex;
        this.list = this.list.concat(res.data.Data);
        if (!res.data.HasNextPage) {
          this.finished = true;
        }
      });
    },
  },
};
</script>